#ifndef CAMERAANIMATION_H
#define CAMERAANIMATION_H

#include "bga/system/TimerListener.h"
#include "bga/graphics/Camera.h"

/**
 * \namespace bga
 * \brief API namespace
 */
namespace bga
{

/*!
 * \class CameraAnimation
 * \brief Defines an animation of the camera between two positions
 *
 *
 */
class BOARD_HELL_ENGINE CameraAnimation : public TimerListener
{
	public:

        /**
         * Constructor
         * \param animationTime : Time of the animation
         * \param camera : camera we animate
         */
		CameraAnimation(float animationTime, Camera* camera);

		/**
		 * Destructor
		 */
		virtual ~CameraAnimation();

        /**
         * \brief Start the animation of the camera until the direction final
         * \param initial : initial direction of the camera
         * \param final : final direction of the camera
         */
		void startAnimation(const Quaternion& initial, const Quaternion& final);

        /**
         * \brief To know if the camera is currently animated
         * \return true if the camera is animated false else
         */
		bool isRunning() const;

		/**
		 * \brief Set the camera to animate
		 * \param camera : camera to animate
		 */
        void setCamera(Camera* camera);

		/*!
         * \brief Function to handle a time elapsed
         * \param event : TimerEvent containing all the information about the sent event
         *
         * Function to handle a time elapsed. This function is abstract.
         */
        virtual void timeElapsed(const bga::TimerEvent &event);

	protected:

	private:
        unsigned int animationTime;  ///!< Time of the animation in milliseconds

        Camera* camera;       ///!< Camera we are moving

        Quaternion initial;   ///!< Initial quaternion. Initial direction of the camera
        Quaternion final;     ///!< Final direction of the camera

        Timer timer;          ///!< Timer used for the animation

        float currentT;       ///!< Current value of the interpolation. 0 <= currentT <= 1

};


}

#endif // CAMERAANIMATION_H

